// pages/recovery/recovery.js
import { getCase } from '../../utils/api.js';
Page({

  /**
   * 页面的初始数据
   */
  data: {
    caseParams: {
      page: 1,
      pageSize: 10
    },
    more: false,
    total:0,
    list:[],
    navbar_id: ''
  },
  scrollToLower(e) {
    if (this.data.more) {
      return;
    }
    this.setData({
      caseParams: {
        page: this.data.caseParams.page + 1,
        pageSize: 10
      }
    })
    this.getData();
  },
  getsph(e) {
    let video_id = e.currentTarget.dataset.info.video_id
    let videoId = wx.getStorageSync('videoId')
    wx.openChannelsActivity({
      finderUserName: videoId,
      feedId: video_id,
      success: (res) => {
        console.log(res)
      },
      fail: (err) => {
        console.log(err)
      }
    })
  },
  getData(){
    let params = { ...this.data.caseParams, navbar: 1, navbar_id: this.data.navbar_id}
    getCase(params).then(res => {
      this.setData({
        list: this.data.list.concat(res.data.list),        
        total: res.data.total
      })
      if (this.data.total == this.data.list.length) {
        this.setData({
          more: true
        })
      }
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    this.setData({
      navbar_id: options.navbar_id
    })
    this.getData()
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
    if (wx.getStorageSync('model1')) {
      wx.setNavigationBarTitle({
        title: wx.getStorageSync('model1')
      })
    }
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})